package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import flc.ast.bean.MyRecordBean;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.basic.adaptermutil.StkSingleSpanProvider;

public class MyWorksAdapter extends StkProviderMultiAdapter<MyRecordBean> {

    public MyWorksAdapter() {
        addItemProvider(new StkSingleSpanProvider<>(35));
        addItemProvider(new MyWorksProvider());
    }

    private class MyWorksProvider extends BaseItemProvider<MyRecordBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_my_works;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, MyRecordBean bean) {
            Glide.with(baseViewHolder.itemView).load(bean.getPath()).into((ImageView) baseViewHolder.getView(R.id.ivMyWorksItemImg));
            if (bean.isSelected()) {
                baseViewHolder.getView(R.id.rlMyWorksItemDelete).setVisibility(View.VISIBLE);
            } else {
                baseViewHolder.getView(R.id.rlMyWorksItemDelete).setVisibility(View.GONE);
            }
        }
    }
}
